<?php

class EncyclopediaController extends BaseController {

	public function index($url) {
		$article = Encyclopedie::url($url)->first();
		if($article->displayChildren == 1) {
			$children = Encyclopedie::where("parent_id","=",$article->article_id)->get();
		}

		$arianeArticle = $article;
		$ariane = array();

		while($arianeArticle !== NULL){
			$ariane[$arianeArticle->article_id] = $arianeArticle;
			$arianeArticle = Encyclopedie::find($arianeArticle->parent_id);
		}

		$ariane = array_reverse($ariane);
		return View::make("encyclopedia.index",compact("article","children","ariane"));
	}
}